@file:Suppress("FINITE_BOUNDS_VIOLATION_IN_JAVA")

package xyz.labmem.base.core.base

import com.alibaba.excel.annotation.ExcelIgnore
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.IdType
import io.swagger.annotations.ApiModelProperty
import com.fasterxml.jackson.annotation.JsonFormat
import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.FieldFill
import com.baomidou.mybatisplus.extension.activerecord.Model
import com.fasterxml.jackson.annotation.JsonIgnore
import java.io.Serializable
import java.util.*

/**
 * 新通用基础字段，需要此通用字段的实体可继承此类
 */
open class BaseEntityInput<T : Model<*>> : Model<T>(), Serializable {

    companion object {
        private const val serialVersionUID = 1L
    }

    /**
     * 自行添加主键
     */
    @TableId(type = IdType.INPUT)
    @ApiModelProperty(value = "主键")
    @ExcelIgnore
    var id: String? = null

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    @ExcelIgnore
    var createTime: Date? = null

    /**
     * 创建人
     */
    @JsonIgnore
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建人")
    @ExcelIgnore
    var createUser: String? = null

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.UPDATE)
    @ApiModelProperty(value = "更新时间")
    @ExcelIgnore
    var updateTime: Date? = null

}